package org.jeecg.modules.basic.demo.school.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;


@JsonIgnoreProperties(ignoreUnknown = true)
public class SchoolTreeModel implements Serializable {

    private static final long serialVersionUID = 1L;

    /** 对应school中的id字段,前端数据树中的key*/
    private String key;

    /** 对应school中的id字段,前端数据树中的value*/
    private String value;

    /** 对应school_name字段,前端数据树中的title*/
    private String title;


    private boolean isLeaf;
    // 以下所有字段均与SysDepart相同
    @TableField(exist = false)
    private String memo;
    private String logo_color;
    private String id;
    private String name;
    private String create_by;
    private Date create_time;
    private String update_by;
    private Date update_time;
    private String sys_org_code;
    private String pid;
    private String has_child;
    private String universityCode;
    private String universitySort;

    private List<SchoolTreeModel> children = new ArrayList<>();


    public SchoolTreeModel(){}

    public SchoolTreeModel(LwgyBaseSchool lwgyBaseSchool) {
        this.memo = lwgyBaseSchool.getMemo();
        this.logo_color = lwgyBaseSchool.getLogoColor();
        this.key = lwgyBaseSchool.getId();
        this.value = lwgyBaseSchool.getId();
        this.title = lwgyBaseSchool.getName();
        this.id = lwgyBaseSchool.getId();
        this.name = lwgyBaseSchool.getName();
        this.create_by = lwgyBaseSchool.getCreateBy();
        this.create_time = lwgyBaseSchool.getCreateTime();
        this.update_by = lwgyBaseSchool.getUpdateBy();
        this.update_time = lwgyBaseSchool.getUpdateTime();
        this.sys_org_code = lwgyBaseSchool.getSysOrgCode();
        this.pid = lwgyBaseSchool.getPid();
        this.has_child = lwgyBaseSchool.getHasChild();
        this.universityCode = lwgyBaseSchool.getUniversityCode();
        this.universitySort = lwgyBaseSchool.getUniversitySort();
    }


    public List<SchoolTreeModel> getChildren() {
        return children;
    }

    public void setChildren(List<SchoolTreeModel> children) {
        if (children==null){
            this.isLeaf=true;
        }
        this.children = children;
    }
    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public boolean isLeaf() {
        return this.isLeaf;
    }

    public void setIsLeaf(boolean isLeaf) {
        this.isLeaf = isLeaf;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCreate_by() {
        return create_by;
    }

    public void setCreate_by(String create_by) {
        this.create_by = create_by;
    }

    public  String getLogo_color(){
        return logo_color;
    }

    public void setLogo_color(String logo_color){
        this.logo_color = logo_color;
    }

    public String getMemo(){return memo;}

    public void setMemo(String memo){this.memo = memo;}

    public Date getCreate_time() {
        return create_time;
    }

    public void setCreate_time(Date create_time) {
        this.create_time = create_time;
    }

    public String getUpdate_by() {
        return update_by;
    }

    public void setUpdate_by(String update_by) {
        this.update_by = update_by;
    }

    public Date getUpdate_time() {
        return update_time;
    }

    public void setUpdate_time(Date update_time) {
        this.update_time = update_time;
    }

    public String getSys_org_code() {
        return sys_org_code;
    }

    public void setSys_org_code(String sys_org_code) {
        this.sys_org_code = sys_org_code;
    }

    public String getPid() {
        return pid;
    }

    public void setPid(String pid) {
        this.pid = pid;
    }

    public String getHas_child() {
        return has_child;
    }

    public void setHas_child(String has_child) {
        this.has_child = has_child;
    }

    public String getUniversity_code() {
        return universityCode;
    }

    public void setUniversity_code(String university_code) {
        this.universityCode = university_code;
    }

    public String getUniversity_sort() {
        return universitySort;
    }

    public void setUniversity_sort(String university_sort) {
        this.universitySort = university_sort;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        SchoolTreeModel school = (SchoolTreeModel) o;
        return Objects.equals(id, school.id) &&
                Objects.equals(name, school.name) &&
                Objects.equals(create_by, school.create_by) &&
                Objects.equals(logo_color, school.logo_color) &&
                Objects.equals(memo,school.memo)&&
                Objects.equals(create_time, school.create_time) &&
                Objects.equals(update_by, school.update_by) &&
                Objects.equals(update_time, school.update_time) &&
                Objects.equals(sys_org_code, school.sys_org_code) &&
                Objects.equals(pid, school.pid) &&
                Objects.equals(has_child, school.has_child) &&
                Objects.equals(universityCode, school.universityCode) &&
                Objects.equals(universitySort, school.universitySort) &&
                Objects.equals(children, school.children);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, create_by, create_time,logo_color, update_by, update_time, sys_org_code, pid, has_child, universityCode, universitySort, children);
    }
}
